<?php
/*
 *   This file is part of verbum.
 *
 *   poat is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   poat is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with poat.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * 	 Copyright (c) 2008 Sergio Gabriel Teves <gabriel.sgt at gmail.com>
 */

if ($op=="save") {
	$ts = new teamsetting;
	$ts->teamid = getTeamId($CURRENT_USER);
	if ($param['autoacc']=="on") {
		$ts->id=AUTO_SEND;
		$loader->save($ts);
	} else {
		$ts->id=AUTO_SEND;
		$loader->delete($ts);
	}
	if ($param['autoreply']=="on") {
		$ts->id=AUTO_REPLY;
		$loader->save($ts);
	} else {
		$ts->id=AUTO_REPLY;
		$loader->delete($ts);
	}
	if ($param['rplheader']=="on") {
		$ts->id=RPL_HEADER;
		$ts->value=$param['rplheadermsg'];
		if ($loader->count($ts->get())) {
			$loader->update($ts);
		} else {
			$loader->save($ts);	
		}
	} else {
		$ts->id=RPL_HEADER;
		$loader->delete($ts);
	}	
	$ts->id=AUTO_REPLY_MSG;
	$ts->value=$param['replymsg'];
	if ($loader->count($ts->get())) {
		$loader->update($ts);
	} else {
		$loader->save($ts);	
	}
	success();
} else {
	include(ROOT_PATH."/form/team_preferences_form.php");
}
?>